package com.yunwx.wechat4j;

import com.yunwx.wechat4j.api.WebWeixinApi;
import com.yunwx.wechat4j.handler.ReceivedMsgHandler;
import com.yunwx.wechat4j.model.ReceivedMsg;
import com.yunwx.wechat4j.model.UserInfo;
import com.yunwx.wechat4j.util.CommonUtil;

import java.util.List;

public class TestClass2 {
    public static void main(String[] args) {
        WebWeixinApi api = new WebWeixinApi();
        Wechat wechat = new Wechat();
        wechat.setWebWeixinApi(api);
        wechat.addReceivedMsgHandler(new ReceivedMsgHandler() {
            @Override
            public void handleAllType(Wechat wechat, ReceivedMsg msg) {
                UserInfo contact = wechat.getContactByUserName(false, msg.getFromUserName());

                List<UserInfo> user = wechat.getContactList(true);
                for (UserInfo ius :user){
                      System.out.println(ius.getUserName()+":"+ius.getNickName());
                    wechat.sendTextToRemarkName("哈喽，来自8月20号的问候："+ius.getNickName(),"李超南");
                }


            }
        });
        wechat.autoLogin();
        CommonUtil.threadSleep(60000);
    }
}
